import 'package:aliyun_vod_upload/model/authInitModel.dart';
import 'package:aliyun_vod_upload/model/stsInitModel.dart';
import 'package:aliyun_vod_upload/model/vodInfoModel.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'aliyun_vod_upload_platform_interface.dart';
import 'model/ResumeWithTokenModel.dart';

/// An implementation of [AliyunVodUploadPlatform] that uses method channels.
class MethodChannelAliyunVodUpload extends AliyunVodUploadPlatform {
  /// The method channel used to interact with the native platform.
  final methodChannel = const MethodChannel('aliyun_vod_upload');

  @override
  Future<String?> getPlatformVersion() async {
    final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<void> initSTSUpLoader(StsInitModel stsInitModel) async{
    await methodChannel.invokeMethod('stsInit', stsInitModel.toJson());
  }

  @override
  Future<void> initAuthUpLoader(AuthInitModel authInitModel) async{
    await methodChannel.invokeMethod('authInit', authInitModel.toJson());
  }

  @override
  Future<void> resumeWithToken(ResumeWithTokenModel resumeWithTokenModel) async{
    await methodChannel.invokeMethod('resumeWithToken', resumeWithTokenModel.toJson());
  }

  @override
  Future<bool> startUpload() async{
    return await methodChannel.invokeMethod('startUpload');
  }

  @override
  Future<bool> addFile(String filePath, VodInfoModel vodInfoModel) async{
    print(filePath);
    print(vodInfoModel.toJson());
    return await methodChannel.invokeMethod('addFile', {"filePath": filePath, "vodInfoModel": vodInfoModel.toJson()});
  }

  @override
  Future<void> clearList() async{
    await methodChannel.invokeMethod('clearList');
  }

  @override
  Future<void> getList() async{
    await methodChannel.invokeMethod('getList');
  }

  @override
  Future<void> resumeFile() async{
    await methodChannel.invokeMethod('resumeFile');
  }

  @override
  Future<void> cancelFile() async{
    await methodChannel.invokeMethod('cancelFile');
  }

  @override
  Future<void> deleteFile() async{
    await methodChannel.invokeMethod('deleteFile');
  }

  @override
  Future<void> resumeUpload() async{
    await methodChannel.invokeMethod('resumeUpload');
  }

  @override
  Future<void> pauseUpload() async{
    await methodChannel.invokeMethod('pauseUpload');
  }

  @override
  Future<void> stopUpload() async{
    await methodChannel.invokeMethod('stopUpload');
  }
}
